const Router = require('koa-router')
const { regValidator } = require('../../validators/validator')
const { User } = require('../../models/user')
const { Success } = require('../../core/http-exception')
const router = new Router({
  prefix: '/v1/user',
})
//注册
router.post('/register', async (ctx, next) => {
  //邮箱,密码,确认密码,昵称
  const x = await new regValidator().validate(ctx)
  const user = {
    phone: x.get('body.phone'),
    password: x.get('body.password'),
    nickName: x.get('body.nickName'),
    avatarUrl: x.get('body.avatarUrl'),
    type: x.get('body.type'),
    gender: x.get('body.gender'),
  }
  await User.create(user)
  ctx.body = {
    code: 200,
    data: true,
  }
})
module.exports = router
